package com.ctgu.service.impl;

import com.ctgu.mapper.HomeworkMapper;
import com.ctgu.service.HomeworkService;
import com.ctgu.vo.Homework;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class HomeworkServiceImpl implements HomeworkService {
    @Resource
    private HomeworkMapper homeworkMapper;

    @Override
    public List<Homework> selectHomeworkByTeacherId(Integer teacherId) {
        return homeworkMapper.selectHomeworkByTeacherId(teacherId);
    }

    @Override
    public List<Homework> selectCourseHomeworkTeacherByStudentId(Integer studentId) {
        return homeworkMapper.selectCourseHomeworkTeacherByStudentId(studentId);
    }

    @Override
    public void insertHomework(String courseId, String homeworkTitle) {
        Homework homework = new Homework();
        homework.setCourseId(courseId);
        homework.setHomeworkTitle(homeworkTitle);
        homeworkMapper.insertSelective(homework);
    }

    @Override
    public void deleteHoemwork(int homeworkId) {
        homeworkMapper.deleteByPrimaryKey(homeworkId);
    }
}
